package com.jvyou.mybatis.demo.mapper;

import com.jvyou.mybatis.annotations.*;
import com.jvyou.mybatis.demo.entity.User;

import java.util.List;

/**
 * @author 橘柚
 * @version 1.0-SNAPSHOT
 * @Date 2024/4/25 20:12
 * @Description
 */
@CacheNamespace
public interface UserMapper {

    @Select("Select count(*) from user")
    Integer count();

    @Select("Select * from user where id = #{id}")
    User findById(@Param("id") Long id);

    @Select("Select * from user where name = #{name}")
    User findByName(@Param("name") String name);

    @Select("Select * from user")
    List<User> findAll();

    @Insert("Insert into user(name,age) values(#{name},#{age})")
    int insert(@Param("name") String name, @Param("age") Integer age);

    @Update("Update user set age = #{age} where name = #{name}")
    int update(@Param("name") String name, @Param("age") Integer age);

    @Delete("Delete from user where name = #{name}")
    int delete(@Param("name") String name);
}
